{% extends 'base.html' %}

{% block title %}搜索{% endblock %}

{% block content %}
<div class="container">
     {% if query %}
        <h1>搜索<span class="font-italic text-danger">{{ query }}</span>的结果: </h1>

        <div class="ml-4">

        {% for result in page.object_list %}
            <div class="border-bottom mt-4">
                <h3>
                    <a href="{{ result.object.get_absolute_url }}">{{ result.object.title }}</a>
                </h3>
            </div>
        {% empty %}
            <p class="text-muted">未查询到结果</p>
        {% endfor %}

        {% if page.has_previous or page.has_next %}
            <div class="mt-3">
                {% if page.has_previous %}<a href="?q={{ query }}&amp;page={{ page.previous_page_number }}">{% endif %}&laquo; 上一页{% if page.has_previous %}</a>{% endif %}
                |
                {% if page.has_next %}<a href="?q={{ query }}&amp;page={{ page.next_page_number }}">{% endif %}下一页 &raquo;{% if page.has_next %}</a>{% endif %}
            </div>
        {% endif %}
    {% else %}
        {# Show some example queries to run, maybe query syntax, something else? #}
    {% endif %}
        </div>
</div>
{% endblock %}
